<?php
require './include/global.php';
require './include/validate.php';
require './include/all_left.php';
accessblock(array("Trial","Standard","Expired"));

require_once './include/advisory_db.php';
//print_r($_SESSION);
$smarty->compile_check = true;

$smarty->display('header.tpl');

$smarty->assign('s',$_GET);
//jobupdate
$smarty->assign('state',$state);
$smarty->assign('chat_public',$chat_public);
$smarty->assign('rec_findchat',$rec_findchat);


$smarty->assign('colors',$colors);
$key = @array_search($_SESSION[usertype],$selectpages);

//print_r($findresume_orderby);
$where = "  WHERE 1=1 AND FIND_IN_SET('".$key."',`sp_selectpage`) AND `sp_status` = 1 ";
$order = " ORDER BY sp_date DESC";

if($_GET[action]=="search"){ 
    $arr = array();
	if($_GET[topic]!=''){ $arr[] = " (`sp_topic`  like '%".$_GET[topic]."%'  OR `sp_description` like '%".$_GET[topic]."%') ";}	
	if($_GET[orderby]=='0'){$by = "sp_id";}
	else{
		$ord   = array('','sp_date','sp_topic','sp_starttime','sp_endtime','sp_timezone','sp_language');
		$by = $ord[$_GET[orderby]];
	}
    if(empty($by)){ $by = "sp_id";}
    if($_GET['date']!='') { $arr[] = " `sp_date` = '".$_GET['date']."'  ";}
	if($_GET[findby]!='') { $arr[] = " `sp_chattype` = '".$_GET[findby]."'  ";}

	if(!empty($arr)){
		$implode  = @implode("AND", $arr);
		$implode  = " AND ".$implode;
		$where    .= $implode;
	}
    $order = " ORDER BY $by DESC";
}

//echo "SELECT * FROM pa_skypechat $where $order";
$nav = new buildNav;
$total = $DB->fetch_one_array("SELECT COUNT(*) AS count FROM pa_skypechat $where");
$nav->total_result = $total[count];
$nav->execute("SELECT * FROM pa_skypechat $where $order");


$page = $nav->pagenav();
//echo $sql2;

$i=0;
while($list2 = $DB->fetch_array($nav->sql_result)){
   $datajob[$i]                   = $list2;
   $datajob[$i][sp_starttime]     = substr($list2[sp_starttime],0,2).":".substr($list2[sp_starttime],2,2);
   $datajob[$i][sp_endtime]     = substr($list2[sp_endtime],0,2).":".substr($list2[sp_endtime],2,2);
   $i++;
}
$smarty->assign("chatlist",$datajob);
$smarty->assign("page",$page);
if($err!=''){
$smarty->assign("err",$err);
}
$smarty->assign("search",$reg_data);
$smarty->display('allleft.tpl');
$smarty->display('findchats.tpl');
$smarty->display('footer.tpl');
?>